package stan;

public class Connection {

//klasa stanu
    private ConnectionState state;

// lista mozliwych stanow
    protected final ConnectionState CONNECTED = new ConnectionStateConnected(this);
    protected final ConnectionState DISCONNECTED = new ConnectionStateDisconnected(this);

    public Connection() {
// domyslny stan -  disconnected
        state = DISCONNECTED;
    }

    public void connect() {
        state.connect();

    }

    public void disconnect() {
        state.disconnect();

    }

    public boolean isConnected() {
        return state.isConnected();

    }

// ustawienie nowego stanu
    protected void setState(ConnectionState state) {
        this.state = state;
    }

}
